package com.inforich.app.api.controller.project;

import com.inforich.app.api.dto.ProjectRubbishExpandDTO;
import com.inforich.app.api.service.IAppProjectRubbishExpandService;
import com.inforich.app.component.LoginUser;
import com.inforich.app.component.LoginUserApp;
import com.inforich.app.component.PreAppRole;
import com.inforich.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 新扩改登记
 * @author: HJM
 * @date: 2022/10/30
 */
@RestController
@RequestMapping("/h5api/projectExpand")
public class AppProjectRubbishExpandController {

  @Autowired
  private IAppProjectRubbishExpandService appProjectRubbishExpandService;

  /**
   * 添加固废申报
   */
  @PostMapping("/add")
  @PreAppRole("project_admin")
  public AjaxResult addProjectReport(@LoginUser LoginUserApp loginUserApp,
      @Validated @RequestBody ProjectRubbishExpandDTO dto) {
    return appProjectRubbishExpandService.addProjectExpand(loginUserApp, dto);
  }

  /**
   * 编辑固废申报
   */
  @PostMapping("/edit")
  @PreAppRole("project_admin")
  public AjaxResult editProjectReport(@LoginUser LoginUserApp loginUserApp,
      @Validated @RequestBody ProjectRubbishExpandDTO dto) {
    return appProjectRubbishExpandService.updateProjectExpand(loginUserApp, dto);
  }

  /**
   * 我的申报
   */
  @GetMapping("/myProjectExpand")
  @PreAppRole("project_admin")
  public AjaxResult myProjectReport(@LoginUser LoginUserApp loginUserApp) {
    return appProjectRubbishExpandService.myProjectExpand(loginUserApp);
  }

}
